﻿/*
Bf3Rcon.NET, provides a .NET implementation of BF3's RCON interface.
Copyright (C) 2011 agentwite, Timi, Unseen, AlCapwn

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

You can contact us at http://bf3rcon.codeplex.com/.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace System.Net.Battlefield3.Server
{
    /// <summary>
    /// Provides data for the <see cref="RconServer.Request"/> event.
    /// </summary>
    /// <remarks>
    /// Typically, a successfull response will being  with the word "OK" followed by any other words.<para />
    /// An unsuccessful response will typically provide one word detailing the error. For instance, if an argument is invalid, only send "InvalidArguments".
    /// </remarks>
    [Serializable]
    public class RequestEventArgs : EventArgs
    {
        /// <summary>
        /// Gets whether or not the client that sent the request is logged on.
        /// </summary>
        /// <value>True if the client is logged on.</value>
        public bool IsLoggedOn { get; private set; }

        /// <summary>
        /// Sets the words that will be sent to the client.
        /// </summary>
        /// <value>The words to be sent to the client in response.</value>
        public IEnumerable<string> ResponseWords { set; get; }

        /// <summary>
        /// Sets the words that will be sent to the client.
        /// </summary>
        /// <param name="words">The words that will be sent to the client.</param>
        /// <remarks>This method is here to make it easier to send simple responses.</remarks>
        public void SetWords(params string[] words)
        {
            ResponseWords = words;
        }

        /// <summary>
        /// Gets the words that were sent by the client.
        /// </summary>
        /// <value>The words sent by the client.</value>
        public ReadOnlyCollection<string> RequestWords { get; private set; }

        /// <summary>
        /// Gets the unique ID for the client that sent the request
        /// </summary>
        /// <value>The ID of the client.</value>
        /// <remarks>This property is not necessary for the RCON protocol, but it is here in case expanded features are being implemented.</remarks>
        public int Id { get; private set; }

        internal RequestEventArgs(ReadOnlyCollection<string> requestWords, bool isLoggedOn, int id)
        {
            RequestWords = requestWords;
            IsLoggedOn = isLoggedOn;
            Id = id;
        }
    }
}
